@@ -37,9 +37,13 @@ describe Agents::PostAgent do |
||
37 | 37 |
data = request.uri.query |
38 | 38 |
else |
39 | 39 |
if data = request.body |
40 |
- case request.headers['Content-Type'] |
|
41 |
- when /json/ |
|
40 |
+ case request.headers['Content-Type'][/\A[^;\s]+/] |
|
41 |
+ when 'application/x-www-form-urlencoded' |
|
42 |
+ # ok |
|
43 |
+ when 'application/json' |
|
42 | 44 |
data = ActiveSupport::JSON.decode(data) |
45 |
+ else |
|
46 |
+ raise "unexpected Content-Type: #{content_type}" |
|
43 | 47 |
end |
44 | 48 |
end |
45 | 49 |
end |
@@ -113,6 +117,15 @@ describe Agents::PostAgent do |
||
113 | 117 |
@sent_requests[:post][0].should == @checker.options['payload'].to_query |
114 | 118 |
end |
115 | 119 |
|
120 |
+ it "sends options['payload'] as JSON as a POST request" do |
|
121 |
+ @checker.options['content_type'] = 'json' |
|
122 |
+ lambda { |
|
123 |
+ @checker.check |
|
124 |
+ }.should change { @sent_requests[:post].length }.by(1) |
|
125 |
+ |
|
126 |
+ @sent_requests[:post][0].should == @checker.options['payload'] |
|
127 |
+ end |
|
128 |
+ |
|
116 | 129 |
it "sends options['payload'] as a GET request" do |
117 | 130 |
@checker.options['method'] = 'get' |
118 | 131 |
lambda { |